﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SchnelleKarten
{
    class CommunityPile
    {
        public List<Card> Pile;

        public CommunityPile()
        {
            Pile = new List<Card>();
        }

        public bool CanAddCard(Card card)
        {
            if (Pile.Capacity == 0 && card.Value == 1)
                return true;
            else if (Pile.Capacity > 0) 
                if (card.Value == Pile.Last<Card>().Value + 1)
                    if ((card.Suit.Equals("Club") && Pile.Last<Card>().Suit.Equals("Club"))
                    || (card.Suit.Equals("Heart") && Pile.Last<Card>().Suit.Equals("Heart"))
                    || (card.Suit.Equals("Diamond") && Pile.Last<Card>().Suit.Equals("Diamond"))
                    || (card.Suit.Equals("Spade") && Pile.Last<Card>().Suit.Equals("Spade")))
                        return true;
            return false;
        }
    }
}
